
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllPigTypes", query = "select myPigType from PigType myPigType"),
		@NamedQuery(name = "findPigTypeById", query = "select myPigType from PigType myPigType where myPigType.id = ?1"),
		@NamedQuery(name = "findPigTypeByMemo", query = "select myPigType from PigType myPigType where myPigType.memo = ?1"),
		@NamedQuery(name = "findPigTypeByMemoContaining", query = "select myPigType from PigType myPigType where myPigType.memo like ?1"),
		@NamedQuery(name = "findPigTypeByName", query = "select myPigType from PigType myPigType where myPigType.name = ?1"),
		@NamedQuery(name = "findPigTypeByNameContaining", query = "select myPigType from PigType myPigType where myPigType.name like ?1"),
		@NamedQuery(name = "findPigTypeByPrimaryKey", query = "select myPigType from PigType myPigType where myPigType.id = ?1") })

@Table(catalog = "pig", name = "pig_type")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "PigType")
@XmlRootElement(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain")
public class PigType implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Name", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String name;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@OneToMany(mappedBy = "pigType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.SaleTaskQuality> saleTaskQualities;
	/**
	 */
	@OneToMany(mappedBy = "pigType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Pig> pigs;
	/**
	 */
	@OneToMany(mappedBy = "pigType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPigsty> taskPigsties;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setSaleTaskQualities(Set<SaleTaskQuality> saleTaskQualities) {
		this.saleTaskQualities = saleTaskQualities;
	}

	/**
	 */
	@JsonIgnore
	public Set<SaleTaskQuality> getSaleTaskQualities() {
		if (saleTaskQualities == null) {
			saleTaskQualities = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.SaleTaskQuality>();
		}
		return saleTaskQualities;
	}

	/**
	 */
	public void setPigs(Set<Pig> pigs) {
		this.pigs = pigs;
	}

	/**
	 */
	@JsonIgnore
	public Set<Pig> getPigs() {
		if (pigs == null) {
			pigs = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Pig>();
		}
		return pigs;
	}

	/**
	 */
	public void setTaskPigsties(Set<TaskPigsty> taskPigsties) {
		this.taskPigsties = taskPigsties;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPigsty> getTaskPigsties() {
		if (taskPigsties == null) {
			taskPigsties = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPigsty>();
		}
		return taskPigsties;
	}

	/**
	 */
	public PigType() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(PigType that) {
		setId(that.getId());
		setName(that.getName());
		setMemo(that.getMemo());
		setSaleTaskQualities(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.SaleTaskQuality>(that.getSaleTaskQualities()));
		setPigs(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Pig>(that.getPigs()));
		setTaskPigsties(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPigsty>(that.getTaskPigsties()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof PigType))
			return false;
		PigType equalCheck = (PigType) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
